﻿@model VietPremier.Models.GetChatOnlineModel
<script type="text/javascript">
    jQuery(document).ready(function () {
        for (var i = 1; i <= 4; i++) {
            checkOnlineSale(i);
        }

    });

    function checkOnlineSale(count) {
        var idSky = ("sky-" + count);
        var sky = $("#" + idSky).attr('title');
        var getURL = '@Url.Action("CheckSky", "Home")';
        $.get(getURL, { "sky": sky }, function (data) {
            if (data == "Online") {
                var online = '@Url.Content("~/Content/cssFrontEnd/images/iconS.png")'
                $("#" + idSky).find('img').attr('src', online);
            } else {
                var online = '@Url.Content("~/Content/cssFrontEnd/images/iconS1.png")'
                $("#" + idSky).find('img').attr('src', online);
            }
        });

        var idYahoo = ("yahoo-" + count);
        var yahoo = $("#" + idYahoo).attr('title');
        getURL = '@Url.Action("CheckYahoo", "Home")';
        $.get(getURL, { "yahoo": yahoo }, function (data) {
            if (data == "Online") {
                var online = '@Url.Content("~/Content/cssFrontEnd/images/iconY.png")'
                $("#" + idYahoo).find('img').attr('src', online);
            } else {
                var online = '@Url.Content("~/Content/cssFrontEnd/images/iconY2.png")'
                $("#" + idYahoo).find('img').attr('src', online);
            }
        });

    }

</script>

<div class="support">
    <div class="online">
        <h5>Hỗ trợ trực tuyến</h5>
        @{                        
            int count = Model.listChatOnline.Count;
            int number = 0;
            for (int i = 0; i < (count % 2 == 0 ? count / 2 : count / 2 + 1); i++)
            {
            <div class="row-fluid">
                @{
                int loop = (2 * i + 2);
                int r = (loop % 2 == 0 ? loop / 2 : loop / 2 + 1);
                for (int j = number; j < (loop % 2 == 0 ? loop / 2 : loop / 2 + 1); j++)
                {
                    if (2 * j < count)
                    {
                    <div class="span6">
                        @{                 
                        var linkSkype = string.Concat("skype:", @Model.listChatOnline[2 * i].Sky, "?chat");
                        var idSky = "sky-" + @Model.listChatOnline[2 * i].Position;
                            <a id="@idSky" href="@Url.Content(linkSkype)" title="@Model.listChatOnline[2 * i].Sky">
                                <img src="" /></a>

                        var linkYahoo = string.Concat("ymsgr:sendIM?", @Model.listChatOnline[2 * i].Yahoo);
                        var idYahoo = "yahoo-" + @Model.listChatOnline[2 * i].Position;
                            <a id="@idYahoo" href="@Url.Content(linkYahoo)" title="@Model.listChatOnline[2 * i].Yahoo">
                                <img src="" /></a>
                            <span>@Model.listChatOnline[2 * i].Name</span>  
                        }
                    </div>   
                    }
                    if (2 * j + 1 < count)
                    {
                    <div class="span6">
                        @{
                        var linkSkype = string.Concat("skype:", @Model.listChatOnline[2 * i + 1].Sky, "?chat");
                        var idSky = "sky-" + @Model.listChatOnline[2 * i + 1].Position;

                            <a id="@idSky" href="@Url.Content(linkSkype)" title="@Model.listChatOnline[2 * i + 1].Sky">
                                <img src="" /></a>                        
                        var linkYahoo = string.Concat("ymsgr:sendIM?", @Model.listChatOnline[2 * i + 1].Yahoo);
                        var idYahoo = "yahoo-" + @Model.listChatOnline[2 * i + 1].Position;
                            <a id="@idYahoo" href="@Url.Content(linkYahoo)" title="@Model.listChatOnline[2 * i + 1].Yahoo">
                                <img src="" /></a>
                            <span>@Model.listChatOnline[2 * i + 1].Name</span>
                        }
                    </div>   
                    }
                    number = (j + 1);
                }
                }
            </div>        
            }
        }

    </div>
    @Html.Action("FollowUs", "Home")
    <div class="clear"></div>
</div>
<!--/ .support-->
